package org.southyin.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.southyin.model.User2;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "LoginServlet4",value = "/login4")
public class LoginServlet4 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        User2 user = new User2();
        user.setId(1001);
        user.setUsername(request.getParameter("username"));
        user.setPasssword(request.getParameter("password"));
        response.getWriter().println(new ObjectMapper().writeValueAsString(user));
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
